package com.ewhale.feitengguest.presenter.user.task;

import com.ewhale.feitengguest.api.ApiHelper;
import com.ewhale.feitengguest.view.user.task.MsgBoardView;
import com.simga.library.base.IPresenter;
import com.simga.library.http.APIException;

import java.util.HashMap;
import java.util.Map;

public class MsgBoardPresenter extends IPresenter {

    public void commitMessage(long missionId,String comment,String imgUrls) {
        mView.showProLoading();
        Map<String,Object> params = new HashMap<>();
        params.put("missionId",missionId);
        params.put("comment",comment);
        params.put("imgUrls",imgUrls);
        request(1, ApiHelper.TASK_API.leaveMessage(params),null);
    }

    @Override
    public <T> void onNext(int postCode, T result, Object data) {
        super.onNext(postCode, result, data);
        switch (postCode){
            case 1:
                ((MsgBoardView)mView).commitSuccess();
                break;
        }
    }

    @Override
    public void otherException(int postCode, Object data, APIException e) {
        super.otherException(postCode, data, e);
        mView.showErrorMessage(postCode,e.getCode(),e.getDisplayMessage());
    }
}
